<html>

<head>
    <meta charset="UTF-8">
    <title></title>
</head>

<body>

    <div id="countdown">还剩 30 分 00 秒</div>

    <script>
        window.onload = function() {

            var countdown = document.getElementById("countdown");


            let currentTime = Date.parse(new Date()); //当前时间戳
            console.log('当前', new Date());

            var  createTime =  Date.parse(new  Date('2020-09-17 09:40:47')); //后台时间戳,可以自定义较新的时间
            console.log('后台', createTime, new  Date('2020-09-17 01:10:47'));

            let seconds = (currentTime - createTime) / 1000; //时间戳差转换成秒

            console.log('时间差', seconds);



            setInterval(function() {
                seconds = seconds - 1;
                var minute = checkFigure(parseInt(seconds / 60));
                var second = checkFigure(parseInt(seconds % 60));
                countdown.innerHTML = '还剩' + minute + '分' + second + '秒';

            }, 1000);
        }

        //把单一位数字通过在前面+“0”转化为两位；
        function checkFigure(i) {
            if (i < 10) {
                i = '0' + i;
            }
            return i;
        }
    </script>

</body>

</html>